package com.shop.controller;

import com.github.pagehelper.PageInfo;
import com.shop.entity.Buyer;
import com.shop.entity.Result;
import com.shop.service.BuyerManagerService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

/**
 * description: 该文件说明
 *
 * @author zhaoxiaozhao（xiaozhao.zhao@ucarinc.com）
 * @version 1.0
 * @date 2018/9/29 16:54
 **/
@Controller
@RequestMapping("/buyerManager")
public class BuyerManagerController {

    @Resource
    private BuyerManagerService buyerManagerService;

    /**
     * description:<会员管理的界面>
     *
     * @author zhaoxiaozhao（xiaozhao.zhao@ucarinc.com）
     * @date   2018/10/9 13:40
     * @param  
     * @return 
     **/
    @RequestMapping("/buyersList")
    public String buyersList(){
        return "buyersList";
    }

    /**
     * description:<会员管理查找>
     *
     * @author zhaoxiaozhao（xiaozhao.zhao@ucarinc.com）
     * @date   2018/10/9 13:40
     * @param  
     * @return 
     **/
    @RequestMapping("/getBuyList")
    @ResponseBody
    public PageInfo<Buyer> getBuyList(@RequestParam(value = "page", defaultValue = "1") Integer page,@RequestParam(value = "rows", defaultValue = "2") Integer rows,Buyer buyer){
        PageInfo<Buyer> pageInfo = buyerManagerService.getBuyerList(page,rows,buyer);
        return pageInfo;
    }

    /**
     * description:<添加会员的页面跳转>
     *
     * @author zhaoxiaozhao（xiaozhao.zhao@ucarinc.com）
     * @date   2018/10/9 13:40
     * @param
     * @return
     **/
    @RequestMapping("/toAddBuyer")
    public String toAddBuyer(){
        return "addBuyer";
    }

    /**
     * description:<新增会员管理>
     *
     * @author zhaoxiaozhao（xiaozhao.zhao@ucarinc.com）
     * @date   2018/10/9 13:40
     * @param
     * @return
     **/
    @RequestMapping("/doAddBuyer")
    @ResponseBody
    public Result doAddBuyer(Buyer buyer){
       return buyerManagerService.addBuyer(buyer);
    }

    /**
     * description:<修改会员的页面跳转>
     *
     * @author zhaoxiaozhao（xiaozhao.zhao@ucarinc.com）
     * @date   2018/10/9 13:40
     * @param
     * @return
     **/
    @RequestMapping("/toModifyBuyer")
    public String toModifyBuyer(){
        return "modifyBuyer";
    }


    /**
     * description:<修改会员的页面>
     *
     * @author zhaoxiaozhao（xiaozhao.zhao@ucarinc.com）
     * @date   2018/10/9 13:40
     * @param
     * @return
     **/
    @RequestMapping("/doModifyBuyer")
    @ResponseBody
    public Result doModifyBuyer(Buyer buyer){
        return buyerManagerService.modifyBuyer(buyer);
    }
    /**
     * description:<修改会员的页有效性>
     *
     * @author zhaoxiaozhao（xiaozhao.zhao@ucarinc.com）
     * @date   2018/10/9 13:40
     * @param
     * @return
     **/
    @RequestMapping("/doDeleteBuyer")
    @ResponseBody
    public Result doDeleteBuyer(@RequestParam(value = "buyerId") String buyerId){
        return buyerManagerService.deleteOrRestoreBuyer(buyerId);
    }


}
